* Apply to:  sfsup_1_scores.csv
* Description:  Plot ideal points of 2012 supervisorial candidates

clear
set more off


import delimited "...\1805 Roadmaps\Figures A7 and A8\sfsup_1_scores.csv", delimiter(comma)


* Fix variable names

rename v1 name
rename v2 party


* Define faction

gen faction = "None"

replace faction = "Moderate" if name=="Engardio"
replace faction = "Moderate" if name=="Garcia"
replace faction = "Moderate" if name=="Crowley"
replace faction = "Moderate" if name=="Lee"

replace faction = "Progressive" if name=="Avalos"
replace faction = "Progressive" if name=="Davis"
replace faction = "Progressive" if name=="Rizzo"
replace faction = "Progressive" if name=="Mar"
replace faction = "Progressive" if name=="Chiu"
replace faction = "Progressive" if name=="Yee"
replace faction = "Progressive" if name=="Olague"
replace faction = "Progressive" if name=="Campos"


* Fix coord1d variable

drop if name=="Bley"
drop if name=="Everett"

rename coord1d coord1d_text

destring coord1d_text, gen(coord1d)
drop coord1d_text


* Define rank

sort coord1d

gen rank = _n


twoway scatter rank coord1d if faction=="Moderate", ///
     mcolor(navy) msymbol(s) msize(large) || ///
     scatter rank coord1d if faction=="Progressive", ///
	 mcolor(maroon) msymbol(t) msize(large) || ///
	 scatter rank coord1d if faction=="None", ///
	 mcolor(black) msymbol(O) msize(large) ///
     xlabel(-1(.5)1) xmlabel(-1.2(.5)1.2, notick nolabel) ///
	 xtitle(" " "{bf:Progressive-Moderate Dimension}") ///
	 ylabel(1(3)22) ymlabel(0(3)24.4, notick nolabel) ///
	 ytitle("{bf:Rank}" " ") ///
     xline(.11, lcolor(gs10)) ///
	 text(9 .70 "{bf:Oppose Alcohol}" "{bf:Recovery Fee}", color(gs10) size(medsmall)) ///
	 text(21 -.6 "{bf:Favor Alcohol}" "{bf:Recovery Fee}", color(gs10) size(medsmall)) ///
 	 text(1 -.95 "{bf:Johnson}", color(black) size(medsmall) placement(e)) ///
 	 text(2 -.95 "{bf:Rizzo}", color(maroon) size(medsmall) placement(e)) ///
 	 text(3 -.95 "{bf:Lagos}", color(black) size(medsmall) placement(e)) ///
 	 text(4 -.93 "{bf:Butler}", color(black) size(medsmall) placement(e)) ///
 	 text(5 -.92 "{bf:Davis}", color(maroon) size(medsmall) placement(w)) ///
 	 text(6 -.62 "{bf:Resignato}", color(black) size(medsmall) placement(e)) ///
 	 text(7 -.57 "{bf:Avalos}", color(maroon) size(medsmall) placement(w)) ///
 	 text(8 -.47 "{bf:Gavin}", color(black) size(medsmall) placement(e)) ///
 	 text(9 -.46 "{bf:Campos}", color(maroon) size(medsmall) placement(w)) ///
 	 text(10 -.31 "{bf:Mar}", color(maroon) size(medsmall) placement(e)) ///
 	 text(11 -.41 "{bf:Pang}", color(black) size(medsmall) placement(w)) ///
 	 text(12 -.36 "{bf:Francis}", color(black) size(medsmall) placement(w)) ///
 	 text(13 -.31 "{bf:Bruno}", color(black) size(medsmall) placement(w)) ///
 	 text(14 -.20 "{bf:Olague}", color(maroon) size(medsmall) placement(e)) ///
 	 text(15 -.28 "{bf:Chiu}", color(maroon) size(medsmall) placement(w)) ///
 	 text(16 -.11 "{bf:Selby}", color(black) size(medsmall) placement(e)) ///
 	 text(17 -.05 "{bf:Rogers}", color(black) size(medsmall) placement(e)) ///
 	 text(18 -.03 "{bf:Breed}", color(black) size(medsmall) placement(w)) ///
 	 text(19 .64 "{bf:Yee}", color(maroon) size(medsmall) placement(w)) ///
 	 text(20 .81 "{bf:Lee}", color(navy) size(medsmall) placement(e)) ///
 	 text(21 .82 "{bf:Engardio}", color(navy) size(medsmall) placement(w)) ///
 	 text(22 .95 "{bf:Garcia}", color(navy) size(medsmall) placement(w)) ///
 	 text(23 .95 "{bf:D'Silva}", color(black) size(medsmall) placement(w)) ///
 	 text(24 .95 "{bf:Crowley}", color(navy) size(medsmall) placement(w)) ///
	 legend(off) plotregion(margin(zero) color(white)) graphregion(color(white))

* End
